package com.kfm.am.lambda;

import java.util.Arrays;
import java.util.Comparator;

public class Test01 {

    public static void main(String[] args) {
        Student stu = new Student("万叶", 23);
        Student stu1 = new Student("林尼", 22);
        Student stu2 = new Student("魈宝", 21);
        Student stu3 = new Student("胡桃", 20);
        Student stu4 = new Student("钟离", 19);
        Student[] students = {stu, stu1, stu2, stu3, stu4};


//        Arrays.sort(students, new Comparator<Student>() {
//            @Override
//            public int compare(Student o1, Student o2) {
//                return o2.getAge() - o1.getAge();
//            }
//        });

        Arrays.sort(students, (o1, o2) -> o2.getAge() - o1.getAge());

        System.out.println(Arrays.toString(students));

    }
}
